<?php
/**
 * 产品推广报告（SP）
 */
namespace App\Logic\Amazon\AdsApi\ReportService;

class SpAdvertisedProduct
{
    use DealReport;
    public static function parse($lines,$accountId,$countryCode): bool
    {
        return DealReport::parseReport($lines,$accountId,$countryCode,'ads_sp_product');
    }

    /**
     * 创建商品推广SP报告
     * 报告类型：推广的商品AP Advertised product reports
     * 广告活动类型：商品推广SP
     * reportTypeId：spAdvertisedProduct
     * @param $config
     * @param $profileId
     * @param $countryCode
     * @param $params
     * @return mixed
     */
    public static function createReport($config,$profileId,$countryCode,$params): mixed
    {
        //所有字段均为必填项
        $configuration = [
            'adProduct' => 'SPONSORED_PRODUCTS',
            'groupBy' => ["advertiser"],
            'columns' => [
                'date','campaignName','adGroupName','advertisedSku','impressions','cost','clicks','spend','sales7d','sales14d','unitsSoldClicks7d','unitsSoldClicks14d'
            ],
            'reportTypeId' => 'spAdvertisedProduct',
            'timeUnit' => 'DAILY',
            'format' => 'GZIP_JSON',
        ];
        return DealReport::createReport($config,$profileId,$countryCode,$params,$configuration);
    }
}
